const mongoose = require("mongoose"); //引入mongose

//连接mongodb数据库
mongoose.connect("mongodb://localhost:27017/H52104", { useNewUrlParser: true, useUnifiedTopology: true })


const db = mongoose.connection;

db.on('open', () => { //连接成功
    console.log('mongodb数据库连接成功');
})

db.on('error', (err) => { //连接出错
    console.log(err);
    console.log('mongodb连接错误');
})




//作业 结合路由 编写一个注册接口

//1.创建路由

//2.用户访问 /users/regist 并且传入username password

//3.客户端接收password username 进行注册=>保存到数据库

//4.postman进行调试

module.exports = mongoose;